package com.neo.impatient.C03_array.C03_05_algorithm

import scala.collection.mutable.ArrayBuffer

object AlgorithmTest {

  def main(args: Array[String]): Unit = {
    val a = Array(1, 7, 2, 9)
    for (i <- a.indices) {
      println(i + " : " + a(i))
    }

    val b = ArrayBuffer(2, 7, 1, 6)

    for (i <- b) {
      println(i)
    }

    println("直接对数组求和")
    println(a.sum)
    println("直接对数组元素求最大值")
    println(b.max)
    println("直接对数组进行排序")
    println(b.sorted)
    println("或者自己提供一个比较函数进行自定义排序")

    println("数组缓冲不可以用块排序")
    scala.util.Sorting.quickSort(a)
    for (i <- a.indices) {
      println(i + " : " + a(i))
    }
  }
}
